---
- hosts: "storages"
  remote_user: ubuntu
  become: yes
  become_method: sudo
  become_user: root
  gather_facts: yes
  connection: ssh
  
  tasks:

    - name: Installing NFS
      apt: 
        name:
          - nfs-kernel-server
        state: present

    - name: Create mountable dir
      file: 
       path: /home/share 
       state: directory 
       mode: 777 
       owner: root 
       group: root

    - name: Enable service nfs, and enable persistently
      service: 
       name: nfs-server
       enabled: yes

    - name: Copy config /etc/exports
      template:
          src: exports
          dest: /etc/exports
          mode: 0644
          owner: root
          group: root

    - name: restart nfs server
      service: 
       name: nfs-kernel-server 
       state: restarted

